%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/badlyBehavedFunction"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 8, 9, 20, 10<br />2: PgSelect[7]<br />ᐳ: Access[24]<br />3: Connection[11]<br />4: ConnectionItems[12]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 11, 24, 12, 20<br /><br />ROOT Connectionᐸ7ᐳ[11]"):::bucket
    Bucket4("Bucket 4 (listItem)<br />Deps: 24, 20<br /><br />ROOT __Item{4}ᐸ12ᐳ[17]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 18, 20<br /><br />ROOT PgSelectSingle{4}ᐸbadly_behaved_functionᐳ[18]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 19, 18, 20, 25<br /><br />ROOT Edge{4}[19]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 18, 20<br /><br />ROOT PgSelectSingle{4}ᐸbadly_behaved_functionᐳ[18]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket4
    Bucket4 --> Bucket5 & Bucket6
    Bucket6 --> Bucket7

    %% plan dependencies
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸbadly_behaved_functionᐳ"]]:::plan
    Object10 --> PgSelect7
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    Connection11[["Connection[11∈0] ➊<br />ᐸ7ᐳ"]]:::plan
    PgSelect7 --> Connection11
    ConnectionItems12[["ConnectionItems[12∈0] ➊"]]:::plan
    Connection11 --> ConnectionItems12
    Access24{{"Access[24∈0] ➊<br />ᐸ7.cursorDetailsᐳ"}}:::plan
    PgSelect7 --> Access24
    Edge19{{"Edge[19∈4]"}}:::plan
    __Item17[/"__Item[17∈4]<br />ᐸ12ᐳ"\]:::itemplan
    PgCursor25{{"PgCursor[25∈4]"}}:::plan
    __Item17 & PgCursor25 --> Edge19
    __Item17 & Access24 --> PgCursor25
    ConnectionItems12 ==> __Item17
    PgSelectSingle18{{"PgSelectSingle[18∈4]<br />ᐸbadly_behaved_functionᐳ"}}:::plan
    __Item17 --> PgSelectSingle18
    List22{{"List[22∈5]<br />ᐸ20,21ᐳ<br />More deps:<br />- Constantᐸ'people'ᐳ[20]"}}:::plan
    PgClassExpression21{{"PgClassExpression[21∈5]<br />ᐸ__badly_be...ion__.”id”ᐳ"}}:::plan
    PgClassExpression21 --> List22
    PgSelectSingle18 --> PgClassExpression21
    Lambda23{{"Lambda[23∈5]<br />ᐸbase64JSONEncodeᐳ"}}:::plan
    List22 --> Lambda23
    PgClassExpression28{{"PgClassExpression[28∈5]<br />ᐸ”c”.”perso...unction__)ᐳ"}}:::plan
    PgSelectSingle18 --> PgClassExpression28
    List30{{"List[30∈7]<br />ᐸ20,29ᐳ<br />More deps:<br />- Constantᐸ'people'ᐳ[20]"}}:::plan
    PgClassExpression29{{"PgClassExpression[29∈7]<br />ᐸ__badly_be...ion__.”id”ᐳ"}}:::plan
    PgClassExpression29 --> List30
    PgSelectSingle18 --> PgClassExpression29
    Lambda31{{"Lambda[31∈7]<br />ᐸbase64JSONEncodeᐳ"}}:::plan
    List30 --> Lambda31
    PgClassExpression33{{"PgClassExpression[33∈7]<br />ᐸ”c”.”perso...unction__)ᐳ"}}:::plan
    PgClassExpression28 o--o PgClassExpression33

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect7,Access8,Access9,Object10,Connection11,ConnectionItems12,Access24 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket4 stroke:#0000ff
    class Bucket4,__Item17,PgSelectSingle18,Edge19,PgCursor25 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression21,List22,Lambda23,PgClassExpression28 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression29,List30,Lambda31,PgClassExpression33 bucket7

